package com.yumeng.doc.config;

import com.yumeng.config.BaseConfiguration;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;

/**
 * SpringDoc默认配置基类
 *
 * @author wxd
 * @date 2024/5/30 下午10:09
 */
public abstract class SpringDocConfiguration extends BaseConfiguration {


    @Bean
    public GroupedOpenApi yumengGroupOpenApi() {
        String[] paths = { "/**" };
        String[] packagedToMatch = {"com.yumeng"};
        return GroupedOpenApi.builder().group("yumeng-doc")
                .displayName("框架文档")
                .pathsToMatch(paths)
                .addOpenApiCustomizer(p->{
                    p.info(new Info()
                            .title("Yumeng-API")
                            .version("3.0.0")
                            .description("Yumeng框架示例文档")
                            .termsOfService("https://www.yumeng.com")
                            .license(new License().name("Apache 2.0"))
                            .contact(new Contact().name("wxd").email("664632213@qq.com")));
                })
/*                .addOpenApiMethodFilter(p->{
                    String aa = p.getName();
                    return true;
                })*/
/*                .addOperationCustomizer((operation, handlerMethod) ->
                        operation.addParametersItem(
                                new HeaderParameter().name("groupCode").example("测试").description("集团code")
                                .schema(new StringSchema()._default("BR2").name("groupCode2").description("集团code2"))
                        )
                )*/
                .packagesToScan(packagedToMatch).build();
    }
}
